<cfcomponent extends="assets.calgrants.com.Base">

	<cfscript>
        import assets.calgrants.com.bo.Institution;
	</cfscript>
	
	<cffunction name="get" access="public" output="false" returntype="assets.calgrants.com.bo.Institution">
		<cfargument name="Institution_ID" type="numeric" required="true" />
		<cfscript>
			if (arguments.Institution_ID gt 0) {
				local.loadArgs = {};
				local.loadArgs.obj = new Institution();
				StructAppend(local.loadArgs, QueryToStruct(read(argumentCollection = arguments))[1]);
				return load(argumentCollection = local.loadArgs);
			} else {
				return new Institution();
			}
		</cfscript>
	</cffunction>		
		
	<cffunction name="load" access="public" output="false" returntype="assets.calgrants.com.bo.Institution">
		<cfargument name="obj" type="assets.calgrants.com.bo.Institution" required="true" />
		<cfscript>
			local.obj = arguments.obj;
			if (IsDefined("arguments.Institution_ID")) {
				local.obj.setInstitution_ID(arguments.Institution_ID);
			}
			if (IsDefined("arguments.Disqualified")) {
				local.obj.setDisqualified(arguments.Disqualified);
			}
			if (IsDefined("arguments.Deleted")) {
				local.obj.setDeleted(arguments.Deleted);
			}
			if (IsDefined("arguments.Approved")) {
				local.obj.setApproved(arguments.Approved);
			}
			if (IsDefined("arguments.Contract_Date")) {
				local.obj.setContract_Date(arguments.Contract_Date);
			}
			if (IsDefined("arguments.Institution_Code")) {
				local.obj.setInstitution_Code(arguments.Institution_Code); 
			}
			if (IsDefined("arguments.Institution")) {                             
				local.obj.setInstitution(arguments.Institution);
			}
			if (IsDefined("arguments.Term_Type")) {
				local.obj.setTerm_Type(arguments.Term_Type);
			}
			if (IsDefined("arguments.Accredited")) {
				local.obj.setAccredited(arguments.Accredited);
			}
			if (IsDefined("arguments.Degree_Granting")) {
				local.obj.setDegree_Granting(arguments.Degree_Granting);
			}
			if (IsDefined("arguments.Segment")) {
				local.obj.setSegment(arguments.Segment);
			}
			if (IsDefined("arguments.Segment_Code")) {
				local.obj.setSegment_Code(arguments.Segment_Code);
			}
			if (IsDefined("arguments.FAO_Last_Name")) {
				local.obj.setFAO_Last_Name(arguments.FAO_Last_Name);
			}
			if (IsDefined("arguments.FAO_First_Name")) {
				local.obj.setFAO_First_Name(arguments.FAO_First_Name);
			}
			if (IsDefined("arguments.FAO_Title")) {
				local.obj.setFAO_Title(arguments.FAO_Title);
			}
			if (IsDefined("arguments.FAO_Phone")) {
				local.obj.setFAO_Phone(arguments.FAO_Phone);
			}
			if (IsDefined("arguments.FAO_Email")) {
				local.obj.setFAO_Email(arguments.FAO_Email);
			}
			if (IsDefined("arguments.FAO_Address1")) {
				local.obj.setFAO_Address1(arguments.FAO_Address1);
			}
			if (IsDefined("arguments.FAO_Address2")) {
				local.obj.setFAO_Address2(arguments.FAO_Address2);
			}
			if (IsDefined("arguments.FAO_City")) {
				local.obj.setFAO_City(arguments.FAO_City);
			}
			if (IsDefined("arguments.FAO_State")) {
				local.obj.setFAO_State(arguments.FAO_State);
			}
			if (IsDefined("arguments.FAO_Zip_Code")) {
				local.obj.setFAO_Zip_Code(arguments.FAO_Zip_Code);
			}
			if (IsDefined("arguments.Payment_Last_Name")) {
				local.obj.setPayment_Last_Name(arguments.Payment_Last_Name);
			}
			if (IsDefined("arguments.Payment_First_Name")) {
				local.obj.setPayment_First_Name(arguments.Payment_First_Name);
			}
			if (IsDefined("arguments.Payment_Title")) {
				local.obj.setPayment_Title(arguments.Payment_Title);
			}
			if (IsDefined("arguments.Payment_Phone")) {
				local.obj.setPayment_Phone(arguments.Payment_Phone);
			}
			if (IsDefined("arguments.Payment_Email")) {
				local.obj.setPayment_Email(arguments.Payment_Email);
			}
			if (IsDefined("arguments.Payment_Address1")) {
				local.obj.setPayment_Address1(arguments.Payment_Address1);
			}
			if (IsDefined("arguments.Payment_Address2")) {
				local.obj.setPayment_Address2(arguments.Payment_Address2);
			}
			if (IsDefined("arguments.Payment_City")) {
				local.obj.setPayment_City(arguments.Payment_City);
			}
			if (IsDefined("arguments.Payment_State")) {
				local.obj.setPayment_State(arguments.Payment_State);
			}
			if (IsDefined("arguments.Payment_Zip_Code")) {
				local.obj.setPayment_Zip_Code(arguments.Payment_Zip_Code);
			}
			if (IsDefined("arguments.Comments")) {
				local.obj.setComments(arguments.Comments);
			}
			if (IsDefined("arguments.Date_Created")) {
				local.obj.setDate_Created(arguments.Date_Created);
			}
			return local.obj;
		</cfscript>
	</cffunction>

	<cffunction name="read" access="public" output="false" returntype="any">
		<cfargument name="Institution_ID" required="false" default="" />
		<cfargument name="Approved" required="false" default="" />
		<cfargument name="Disqualified" required="false" default="" />
		<cfargument name="Deleted" required="false" default="0" />
		<cfargument name="Contract_Date" required="false" default="" />
		<cfargument name="Institution_Code" required="false" default="" />
		<cfargument name="Institution" required="false" default="" />
		<cfargument name="Term_Type" required="false" default="" />
		<cfargument name="Accredited" required="false" default="" />
		<cfargument name="Degree_Granting" required="false" default="" />
		<cfargument name="Segment" required="false" default="" />
		<cfargument name="Segment_Code" required="false" default="" />
		<cfargument name="FAO_Last_Name" required="false" default="" />
		<cfargument name="FAO_First_Name" required="false" default="" />
		<cfargument name="FAO_Title" required="false" default="" />
		<cfargument name="FAO_Phone" required="false" default="" />
		<cfargument name="FAO_Email" required="false" default="" />
		<cfargument name="FAO_Address1" required="false" default="" />
		<cfargument name="FAO_Address2" required="false" default="" />
		<cfargument name="FAO_City" required="false" default="" />
		<cfargument name="FAO_State" required="false" default="" />
		<cfargument name="FAO_Zip_Code" required="false" default="" />
		<cfargument name="Payment_Last_Name" required="false" default="" />
		<cfargument name="Payment_First_Name" required="false" default="" />
		<cfargument name="Payment_Title" required="false" default="" />
		<cfargument name="Payment_Phone" required="false" default="" />
		<cfargument name="Payment_Email" required="false" default="" />
		<cfargument name="Payment_Address1" required="false" default="" />
		<cfargument name="Payment_Address2" required="false" default="" />
		<cfargument name="Payment_City" required="false" default="" />
		<cfargument name="Payment_State" required="false" default="" />
		<cfargument name="Payment_Zip_Code" required="false" default="" />
		<cfargument name="Comments" required="false" default="" />
		<cfargument name="Date_Created" required="false" default="" />
		<cfargument name="hasScholarships" required="false" default="1" />

		<cfset var recs = "">
		<cfstoredproc datasource="#getDatasource()#" procedure="readInstitution">
			<cfprocparam value="#arguments.Institution_ID#" cfsqltype="CF_SQL_INTEGER" null="#IIf(Len(Trim(arguments.Institution_ID)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Approved#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Approved)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Disqualified#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Disqualified)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Deleted#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Deleted)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Contract_Date#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Contract_Date)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Institution_Code#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Institution_Code)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Institution#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Institution)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Term_Type#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Term_Type)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Accredited#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Accredited)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Degree_Granting#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.Degree_Granting)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Segment#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Segment)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Segment_Code#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Segment_Code)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.FAO_Last_Name#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.FAO_Last_Name)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.FAO_First_Name#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.FAO_First_Name)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.FAO_Title#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.FAO_Title)) eq 0, true, false)#" />
			<cfprocparam value="#formatPhone(arguments.FAO_Phone)#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.FAO_Phone)) eq 0, true, false)#" />
			<cfprocparam value="#LCase(arguments.FAO_Email)#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.FAO_Email)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.FAO_Address1#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.FAO_Address1)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.FAO_Address2#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.FAO_Address2)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.FAO_City#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.FAO_City)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.FAO_State#" cfsqltype="CF_SQL_CHAR" null="#IIf(Len(Trim(arguments.FAO_State)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.FAO_Zip_Code#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.FAO_Zip_Code)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Payment_Last_Name#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Payment_Last_Name)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Payment_First_Name#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Payment_First_Name)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Payment_Title#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Payment_Title)) eq 0, true, false)#" />
			<cfprocparam value="#formatPhone(arguments.Payment_Phone)#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Payment_Phone)) eq 0, true, false)#" />
			<cfprocparam value="#LCase(arguments.Payment_Email)#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Payment_Email)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Payment_Address1#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Payment_Address1)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Payment_Address2#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Payment_Address2)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Payment_City#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Payment_City)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Payment_State#" cfsqltype="CF_SQL_CHAR" null="#IIf(Len(Trim(arguments.Payment_State)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Payment_Zip_Code#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Payment_Zip_Code)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Comments#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(arguments.Comments)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.Date_Created#" cfsqltype="CF_SQL_TIMESTAMP" null="#IIf(Len(Trim(arguments.Date_Created)) eq 0, true, false)#" />
			<cfprocparam value="#arguments.hasScholarships#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(arguments.hasScholarships)) eq 0, true, false)#" />
			<cfprocresult name="recs" />
		</cfstoredproc>
		<cfreturn recs />
	</cffunction>

	<cffunction name="save" access="public" output="false" returntype="any">
		<cfargument name="institution" required="true" type="assets.calgrants.com.bo.Institution" />

		<cfstoredproc datasource="#getDatasource()#" procedure="saveInstitution">
			<cfprocparam value="#institution.getInstitution_ID()#" cfsqltype="CF_SQL_INTEGER" variable="id" type="inout" null="false" />
			<cfprocparam value="#institution.getApproved()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#institution.getDisqualified()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#institution.getDeleted()#" cfsqltype="CF_SQL_BIT" null="false" />
			<cfprocparam value="#institution.getContract_Date()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getContract_Date())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getInstitution_Code()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getInstitution_Code())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getInstitution()#" cfsqltype="CF_SQL_VARCHAR" null="false" />
			<cfprocparam value="#institution.getTerm_Type()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getTerm_Type())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getAccredited()#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(institution.getAccredited())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getDegree_Granting()#" cfsqltype="CF_SQL_BIT" null="#IIf(Len(Trim(institution.getDegree_Granting())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getSegment()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getSegment())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getSegment_Code()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getSegment_Code())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getFAO_Last_Name()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getFAO_Last_Name())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getFAO_First_Name()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getFAO_First_Name())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getFAO_Title()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getFAO_Title())) eq 0, true, false)#" />
			<cfprocparam value="#formatPhone(institution.getFAO_Phone())#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getFAO_Phone())) eq 0, true, false)#" />
			<cfprocparam value="#LCase(institution.getFAO_Email())#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getFAO_Email())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getFAO_Address1()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getFAO_Address1())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getFAO_Address2()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getFAO_Address2())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getFAO_City()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getFAO_City())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getFAO_State()#" cfsqltype="CF_SQL_CHAR" null="#IIf(Len(Trim(institution.getFAO_State())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getFAO_Zip_Code()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getFAO_Zip_Code())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getPayment_Last_Name()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getPayment_Last_Name())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getPayment_First_Name()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getPayment_First_Name())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getPayment_Title()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getPayment_Title())) eq 0, true, false)#" />
			<cfprocparam value="#formatPhone(institution.getPayment_Phone())#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getPayment_Phone())) eq 0, true, false)#" />
			<cfprocparam value="#LCase(institution.getPayment_Email())#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getPayment_Email())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getPayment_Address1()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getPayment_Address1())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getPayment_Address2()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getPayment_Address2())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getPayment_City()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getPayment_City())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getPayment_State()#" cfsqltype="CF_SQL_CHAR" null="#IIf(Len(Trim(institution.getPayment_State())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getPayment_Zip_Code()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getPayment_Zip_Code())) eq 0, true, false)#" />
			<cfprocparam value="#institution.getComments()#" cfsqltype="CF_SQL_VARCHAR" null="#IIf(Len(Trim(institution.getComments())) eq 0, true, false)#" />
		</cfstoredproc>
		<cfreturn id />
	</cffunction>

	<cffunction name="destroy" access="public" output="false" returntype="any">
		<cfargument name="Institution_ID" required="true" />

		<cfstoredproc datasource="#getDatasource()#" procedure="destroyInstitution">
			<cfprocparam value="#arguments.Institution_ID#" cfsqltype="CF_SQL_INTEGER" null="false" />
			<cfprocparam value="true" cfsqltype="CF_SQL_BIT" null="false" />
		</cfstoredproc>
		<cfreturn true />
	</cffunction>

</cfcomponent>

